{-# LANGUAGE Rank2Types, FlexibleContexts, QuasiQuotes, ScopedTypeVariables #-}

{- |

Module      :  Examples.PV
Copyright   :  (c) The University of Kansas 2011
License     :  BSD3

Maintainer  :  nicolas.frisby@gmail.com
Stability   :  experimental
Portability :  see LANGUAGE pragmas (... GHC)

Polymorphic variants via yoko.

-}
module Examples.PV where

import Data.Yoko

newtype PV tag rep = PV (RMI rep)

pv :: [qP|tag|] -> RMI rep -> PV tag rep
pv _ x = PV x

unPV :: forall tag rep t. (t ::: HasTagRepU tag rep) => PV tag rep -> t
unPV (PV x) = hasTagRepU (membershipIn [qP|HasTagRepU tag rep :: *->*|]) x

pvDC :: forall dc. Generic dc => RMNI dc -> PV (Tag dc) (Rep dc)
pvDC = pv [qP|Tag dc|] . rep

